﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Runtime.InteropServices;

namespace DSTIFIMTR01
{ 
      /*
         * Public Method CloseComm 关闭comm 端口 
         * Public Method ExecuteCommand 执行命令 
         * Public Method GetDataPart 获取指定数据部分 
         * Public Method OpenComm 打开com 口 
         */
    
    public class MabuCommAPI
    {
        [DllImport("user32.dll")]   
        public static extern IntPtr FindWindow(string lpClassName, string lpWindowName); 
        [DllImport("user32.dll")] 
        public static extern IntPtr FindWindowEx(IntPtr hwndParent,IntPtr hwndChildAfter,string lpszClass,string lpszWindow); 
        [DllImport("user32.dll", CharSet=CharSet.Unicode)]    
        public static extern IntPtr PostMessage(IntPtr hwnd,int wMsg,IntPtr wParam,IntPtr lParam);  
          [DllImport("user32.dll", CharSet=CharSet.Unicode)]
        public static extern IntPtr SendMessage(IntPtr hwnd, int wMsg, IntPtr wParam, string lParam);  

        [DllImport("MabuComm.dll", CallingConvention = CallingConvention.Winapi)]
          public static extern void comm();
        [DllImport("MabuComm.dll", CallingConvention = CallingConvention.StdCall)]
        public static extern void CloseComm();
        [DllImport("MabuComm.dll", CallingConvention = CallingConvention.StdCall)]
        public static extern void ExecuteCommand();
        [DllImport("MabuComm.dll", CallingConvention = CallingConvention.StdCall)]
        public static extern void GetDataPart();
        [DllImport("MabuComm.dll", CallingConvention = CallingConvention.StdCall)]
        public static extern void OpenComm();
         
 
    }
}
